package com.storeroompda;

import android.app.Application;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;

import com.storeroompda.dao.DaoMaster;
import com.storeroompda.dao.DaoSession;

public class App extends Application {
    private String tag="App";
    public static SharedPreferences sSharedPreferences;
    public static SharedPreferences.Editor sEditor;
    public static final String SHARE_KEY="SHARE_KEY";
    public static DaoSession daoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        sSharedPreferences = getSharedPreferences(SHARE_KEY, MODE_PRIVATE);
        sEditor = sSharedPreferences.edit();
        setupDatabase();
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
    }

    public void setupDatabase() {
        //创建数据库shop.db
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "sroreroom.db", null);
        //获取可写数据库
        SQLiteDatabase db = helper.getWritableDatabase();
        //获取数据库对象
        DaoMaster daoMaster = new DaoMaster(db);
        //获取dao对象管理者
        daoSession = daoMaster.newSession();
    }
}


